package com.example.deliveryapplication

import android.content.Context
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.SpinnerAdapter
import android.widget.TextView
import com.example.deliveryapplication.entity.SelectString

class StringListSpinnerAdapter(private val context: Context, private val items: List<SelectString>) : BaseAdapter(), SpinnerAdapter {

    override fun getCount(): Int {
        return items.size
    }

    override fun getItem(position: Int): Any {
        return items[position]
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        val textView = TextView(context)
        textView.textSize=18F
        textView.text = items[position].name
        textView.gravity=Gravity.END
        return textView
    }

    override fun getDropDownView(position: Int, convertView: View?, parent: ViewGroup?): View {
        val textView = TextView(context)
        textView.textSize=20F
        textView.gravity=Gravity.CENTER
        textView.text = items[position].name
        return textView
    }
}